package com.lw.spring.javademo.trans;


import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
@WebServlet("/first")
public class FirstServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 设置一个请求属性
        request.setAttribute("message", "Hello from FirstServlet!");

        // 请求转发到第二个 Servlet
        RequestDispatcher dispatcher = request.getRequestDispatcher("/second");
        dispatcher.forward(request, response);  // 转发请求
    }
}

